<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>回收袋子</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css?123456" media="all" /></head>

<body class="childrenBody">
<form class="layui-form">
	<blockquote class="layui-elem-quote quoteBox" id="tool">
		<div class="layui-inline">
			<label class="layui-input-inline">编号</label>
			<label class="layui-input-inline">
				<input type="text" class="layui-input" name="cardNo" placeholder="请输入编号" />
			</label>
			<a class="layui-btn search_btn" lay-submit="" lay-filter="seacherBtn">搜索</a></div>
		<div class="layui-inline">
			<a class="layui-btn layui-btn-normal addBtn" data-title="添加" data-url="/recoverySack/getEntity">添加</a>
			<a class="layui-btn export_btn" lay-submit="" >模板导出</a>
			<button id="importData" type="button" class="layui-btn import_btn" >导入</button>
		</div>
	</blockquote>
	<table id="entityList" lay-filter="entityList"></table>
</form>
<script type="text/html" id="entityBar">
	<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="edit">编辑</a>
	<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a >
</script>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['jquery', 'pageUtil', 'table', 'dateUtil','upload'],
    function() {
        var $ = layui.jquery,
            dateUtil = layui.dateUtil,
            table = layui.table,
			upload = layui.upload,
            pageUtil = layui.pageUtil;
        var tableIns = null;
        var url = "/recoverySack/page";
        var cols = [{
            type: 'checkbox',
            fixed: 'left'
        },
            {
                type: 'numbers',
                title: '序号'
            },
            {
                field: 'cardNo',
                title: '编号',
                align: 'center'
            },
           /* {field: 'qrImage', title: '二维码',align:'center', templet:function(d){
				if(d.qrImage != null && d.qrImage != ""){
					return "<img lay-event ='showPicture'  src='"+d.qrImage+"' style='width:auto; max-width: 96%; height: 80px;'/>";
				}else{
					return "无";
				}
			},width:100},*/
            {field: 'status', title: '状态',align:'center', templet:function(d){
				if (d.status == "1") {
					return "未使用";
				} else if (d.status == "2") {
					return "已使用";
				}
			},width:100},
            {
                field: 'createTime',
                title: '创建时间',
                width: 190,
                align: 'center',
                templet: function(d) {
                    return dateUtil.formatDate(new Date(d.createTime), "yyyy-MM-dd HH:mm:ss");
                }
            },
            {
                title: '操作',
                width: 150,
                templet: '#entityBar',
                align: "center",
                fixed: 'right'
            }];
        tableIns = pageUtil.initDate(cols, url, true);

		$(".export_btn").on("click",function(){
			window.location.href = "/recoverySack/exportMould";
		});

		layui.upload.render({
			elem: "#importData",//导入id
			url: "/recoverySack/importData",
			// size: '3072',
			accept: "file",
			exts: 'xls|xlsx|xlsm|xlt|xltx|xltm',
			done: function (result) {
				if (result.status == 0) {
					tableIns.reload();
				}
				if (result.msg != null) {
					tableIns.reload();
					layer.msg(result.msg)
				}
			}
		});

        table.on('tool(entityList)',
            function(obj) {
                var layEvent = obj.event,
                    data = obj.data;
                if (layEvent === 'edit') {
                    pageUtil.editPopup("编辑", "/recoverySack/getEntity?id=" + data.id);
                } else if (layEvent === 'del') {
                    pageUtil.delete("确定删除该项吗？", "/recoverySack/delete", {
                            "id": data.id,
                            "_method": "DELETE"
                        },
                        function(data) {
                            tableIns.reload();
                        });
                }
            });
    })</script>
</body>

</html>